package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.MemberMobPosInfo;
import com.topscore.uke.mvp.contractors.GetMemberMobPosInfoContractor;
import com.topscore.uke.mvp.model.GetMemberMPosModel;
import com.topscore.uke.network.BaseResponse;

/**
 * Created by 71468 on 2017/11/13.
 */

public class GetMemberMPosPresenter implements GetMemberMobPosInfoContractor.Presenter,GetMemberMobPosInfoContractor {
    private View mView;
    private Model mModel;

    public GetMemberMPosPresenter(View view) {
        this.mView = view;
        this.mModel = new GetMemberMPosModel(new CallBack() {
            @Override
            public void onGetSuccess(BaseResponse<MemberMobPosInfo> response) {
                MemberMobPosInfo info = response.getData();
                mView.getNickNameTv().setText(info.getNickName());
                mView.getPhoneTv().setText(info.getPhone());
                mView.BirthDayTv().setText(info.getGregorianBirthday());
                mView.getAddressAdapter().setNewData(info.getAddress());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode,errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void getMobPosInfoByPhone(String phone) {
        mView.onLoading("正在获取会员信息");
        mModel.getInfo(phone);
    }
}
